{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5304ad78",
   "metadata": {},
   "source": [
    "# 画分子运动"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0ad98d3a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.0 1.0 0.7071067811865471 1.2247448713915896\n",
      "1.2247448713915896 1.0 0.7071067811865481 1.4142135623730954\n",
      "1.4142135623730954 1.0 0.9999999999999041 1.4142135623731633\n",
      "0.7071067811865481 1.0 1.1180339887498951 0.5000000000000003\n",
      "0.7071067811865471 1.1180339887498951 0.9928253927028057 0.8742412365042724\n",
      "0.9928253927028057 0.8742412365042724 0.6580716235778963 1.147580819917077\n",
      "0.9999999999999041 1.0 1.276142374917427 0.6094757082443214\n",
      "0.6094757082443214 0.5000000000000003 0.6471139466823895 0.4502268083411505\n",
      "1.0 0.4502268083411505 0.9004412995506962 0.6260268724364093\n",
      "1.276142374917427 0.6471139466823895 0.930915907818224 1.0865962422269464\n",
      "0.930915907818224 1.0 0.08967283679792035 1.3632913150789312\n",
      "0.6580716235778963 1.3632913150789312 1.3550569660551406 0.6748644977130804\n",
      "1.3550569660551406 0.6748644977130804 0.8803822057972643 1.2314822951401425\n",
      "1.147580819917077 1.0865962422269464 1.4905350169262772 0.525298481988911\n",
      "1.4142135623731633 0.6260268724364093 1.0370783338383822 1.1473352493912623\n",
      "0.8803822057972643 1.1473352493912623 1.2423413161049313 0.7402966007478583\n",
      "0.9004412995506962 1.2314822951401425 0.7388145403148593 1.3347270328421172\n",
      "1.2423413161049313 0.08967283679792035 1.2153855423190332 0.2725640234561212\n",
      "1.4905350169262772 0.7402966007478583 1.657927265221404 0.14495129181117322\n",
      "1.2153855423190332 1.3347270328421172 1.6923314726106804 0.628229620034761\n",
      "0.628229620034761 1.0370783338383822 0.7244097401935893 0.9723345382730534\n",
      "0.7388145403148593 0.7244097401935893 0.22103736871509777 1.0108208932840208\n",
      "1.6923314726106804 1.657927265221404 1.685802590059858 1.664565486035509\n",
      "0.525298481988911 1.0108208932840208 0.8834491326048594 0.7191766150112794\n",
      "0.2725640234561212 0.7191766150112794 0.5737135847104774 0.512209794108161\n",
      "0.22103736871509777 0.8834491326048594 0.45101299146152185 0.7911555913988737\n",
      "0.5737135847104774 0.7911555913988737 0.4343273718367535 0.8754622671231616\n",
      "0.8754622671231616 0.9723345382730534 0.26638647616763733 1.2809788760124368\n",
      "0.512209794108161 0.14495129181117322 0.5141804266272949 0.13779781947268077\n",
      "1.664565486035509 1.2809788760124368 1.560081239545265 1.40635403227979\n",
      "1.685802590059858 0.13779781947268077 1.5438731381219255 0.690922821369732\n",
      "1.560081239545265 0.45101299146152185 0.9599046107090146 1.3099043212340877\n",
      "1.5438731381219255 0.4343273718367535 1.527816736074001 0.4878120063233897\n",
      "1.527816736074001 0.26638647616763733 1.5470533138139875 0.10868200370799443\n",
      "0.10868200370799443 0.690922821369732 0.5018452967615221 0.48717288629175065\n",
      "1.3099043212340877 0.5018452967615221 1.3269743398557787 0.4547935070267783\n",
      "1.5470533138139875 0.5141804266272949 0.6449484878166026 1.497263141526079\n",
      "0.6449484878166026 1.40635403227979 1.4401490824722982 0.5654739925944823\n",
      "1.497263141526079 0.48717288629175065 1.275895140835539 0.9226190577386956\n",
      "1.4401490824722982 0.4878120063233897 0.6710409616054391 1.3644390646367104\n",
      "0.6710409616054391 1.3269743398557787 0.6667444284120061 1.32913834418001\n",
      "0.6667444284120061 0.9226190577386956 0.5795138811730003 0.9797641144933291\n",
      "1.32913834418001 0.9797641144933291 1.3766479827649658 0.9118041399158183\n",
      "1.3644390646367104 0.5654739925944823 1.2391567267957124 0.8037072874152513\n",
      "0.5795138811730003 0.9599046107090146 0.49969531602670914 1.0037717824653103\n",
      "1.3766479827649658 0.4547935070267783 0.43163036976652003 1.3840852670192625\n",
      "1.3840852670192625 0.8037072874152513 0.692157057395262 1.4431063848940926\n",
      "1.0037717824653103 1.275895140835539 1.3221899802387607 0.9419553374961854\n",
      "1.2391567267957124 1.4431063848940926 0.2517939797170251 1.8853819834355645\n",
      "0.2517939797170251 0.692157057395262 0.27644792349391306 0.6826845141935689\n",
      "1.3221899802387607 0.43163036976652003 0.5411864437297574 1.2812526499764576\n",
      "0.49969531602670914 1.2812526499764576 0.5023754351351469 1.2802041571966165\n",
      "0.6826845141935689 0.9118041399158183 0.43708849481862405 1.051854829900269\n",
      "0.5411864437297574 1.2802041571966165 0.631208229723422 1.2382978727712428\n",
      "0.5023754351351469 1.2382978727712428 1.3010705680303045 0.3049230665960092\n",
      "1.3010705680303045 1.051854829900269 0.8087666997481056 1.464609037100953\n",
      "0.631208229723422 0.9419553374961854 0.6184676068975323 0.9503691421371845\n",
      "0.3049230665960092 1.8853819834355645 1.272031206371303 1.4246332545688047\n",
      "0.6184676068975323 1.4246332545688047 1.5482167619238822 0.12291032870672244\n",
      "1.272031206371303 0.12291032870672244 1.1722713430332807 0.5088715330888292\n",
      "1.1722713430332807 0.5088715330888292 0.6708569131319866 1.0877138139180955\n",
      "0.8087666997481056 0.43708849481862405 0.5560747782537129 0.7320729252706569\n",
      "0.6708569131319866 0.7320729252706569 0.64943594262181 0.7511409469881372\n",
      "0.9503691421371845 1.464609037100953 1.214231496740194 1.254560883420337\n",
      "1.5482167619238822 0.7511409469881372 1.435779932499182 0.9485377428320658\n",
      "0.64943594262181 1.0877138139180955 0.8318560442229189 0.9554600495296102\n",
      "1.435779932499182 1.214231496740194 1.3870960014890084 1.2695616664410172\n",
      "1.2695616664410172 1.254560883420337 0.8066956088233829 1.5921532683162074\n",
      "1.3870960014890084 0.8318560442229189 0.9771732596965725 1.2888569417088045\n",
      "0.9485377428320658 0.9554600495296102 1.2282404088376038 0.5514102410388403\n",
      "0.5514102410388403 1.5921532683162074 1.5397441425687077 0.6842464900588449\n",
      "1.5397441425687077 0.6842464900588449 0.3799450441297219 1.6415380127105668\n",
      "1.2282404088376038 0.8066956088233829 1.2404880967903849 0.7877319270652045\n",
      "1.2888569417088045 1.6415380127105668 0.9279062354439389 1.8694355516007999\n",
      "0.9279062354439389 1.2404880967903849 1.227994161970892 0.9443786519292883\n",
      "1.227994161970892 0.9443786519292883 0.8587210933464174 1.2893482011839579\n",
      "0.5560747782537129 0.27644792349391306 0.32024037321797677 0.5320608205602282\n",
      "0.8587210933464174 1.2893482011839579 0.8709396808449591 1.281126368624132\n",
      "0.5320608205602282 1.8694355516007999 1.1955399378149179 1.5325019593637434\n",
      "1.1955399378149179 0.3799450441297219 0.965333501491757 0.8011274619977135\n",
      "0.7877319270652045 1.5325019593637434 0.6632761061957838 1.59032973037711\n",
      "0.965333501491757 0.6632761061957838 0.8368055583674217 0.8194879008490392\n",
      "0.9771732596965725 0.8709396808449591 0.43650531912398693 1.2340448182755805\n",
      "0.8368055583674217 0.8011274619977135 1.0896692308247846 0.3932807143443882\n",
      "1.281126368624132 1.59032973037711 1.8489101905218637 0.867158884570637\n",
      "0.32024037321797677 1.8489101905218637 1.7404970474987052 0.7012081124050652\n",
      "1.2340448182755805 0.3932807143443882 0.7476786822380154 1.0575977127031184\n",
      "0.43650531912398693 0.7012081124050652 0.38897151532891544 0.7286500331358914\n",
      "0.38897151532891544 1.0575977127031184 0.0901115718237704 1.1232504913311143\n",
      "0.7286500331358914 1.1232504913311143 1.1219501021401748 0.7306507410330714\n",
      "1.1219501021401748 0.8194879008490392 1.0902865923455825 0.8611664170656976\n",
      "1.7404970474987052 0.0901115718237704 1.502840632164988 0.88256450304904\n",
      "1.502840632164988 1.0896692308247846 1.0330988557823142 1.5422761596010013\n",
      "0.7476786822380154 0.8611664170656976 0.4255400050402907 1.0580863451841989\n",
      "1.5422761596010013 0.867158884570637 0.6408147180376145 1.6492230839731106\n",
      "0.6408147180376145 1.0580863451841989 0.622182476391346 1.0691488122756416\n",
      "0.622182476391346 1.0902865923455825 0.6528924900720978 1.072178755518158\n",
      "0.88256450304904 0.4255400050402907 0.43898888679799486 0.8759527128788099\n",
      "0.43898888679799486 1.0691488122756416 0.4325010685880685 1.07178974206359\n",
      "1.07178974206359 0.7306507410330714 1.2238656148528324 0.42981008986040825\n",
      "1.072178755518158 1.6492230839731106 0.7926563617627188 1.8003332904357832\n",
      "0.7926563617627188 0.42981008986040825 0.4541828309405561 0.7789472236727881\n",
      "1.2238656148528324 1.8003332904357832 1.6830537236305525 1.3807161776570032\n",
      "1.0330988557823142 0.8759527128788099 1.185632842836053 0.6548749216506712\n",
      "0.4541828309405561 1.3807161776570032 1.414179659962781 0.33579025672657037\n",
      "0.6548749216506712 0.7789472236727881 0.5176170941797739 0.8761806229810177\n",
      "1.6830537236305525 0.8761806229810177 0.5519219702660334 1.815418535614235\n",
      "1.414179659962781 0.5519219702660334 0.3315721909817361 1.4814121148695787\n",
      "1.185632842836053 0.33579025672657037 0.9352770274330046 0.8023323603595207\n",
      "1.4814121148695787 1.815418535614235 1.8416807920111506 1.4486332088804503\n",
      "0.9352770274330046 0.5176170941797739 0.7476860746376545 0.7639608026750887\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.6528924900720978 0.7639608026750887 0.5467984137493339 0.8431584704773609\n",
      "1.4486332088804503 0.8023323603595207 1.554972960996182 0.569503714581491\n",
      "0.7476860746376545 1.554972960996182 1.5019225946324455 0.8492372432770722\n",
      "1.5019225946324455 1.8416807920111506 1.5605968245759794 1.792232454525262\n",
      "0.4325010685880685 1.792232454525262 0.6811737642272785 1.7132298877593477\n",
      "0.5467984137493339 0.569503714581491 0.526749970202983 0.5880964675051712\n",
      "1.5605968245759794 0.526749970202983 1.578613085163318 0.47000926303278845\n",
      "0.8431584704773609 1.7132298877593477 1.709300330278962 0.8510964901571737\n",
      "0.3315721909817361 0.5880964675051712 0.5868093835882344 0.3338447547248361\n",
      "0.5868093835882344 0.8510964901571737 0.5483722491924397 0.8763551589057308\n",
      "0.6811737642272785 0.8492372432770722 0.6359906677469809 0.8835821766984384\n",
      "0.47000926303278845 0.8763551589057308 0.9306420909450561 0.35044595936995404\n",
      "0.5483722491924397 0.35044595936995404 0.3315194895144786 0.5600172516942332\n",
      "1.578613085163318 0.8835821766984384 1.735034392494724 0.5122425133552111\n",
      "0.6359906677469809 0.3338447547248361 0.13609141530698873 0.7052769501396435\n",
      "1.735034392494724 0.9306420909450561 0.3490288377600581 1.937683646777767\n",
      "1.937683646777767 0.7052769501396435 0.29719767993136853 2.0405163636765264\n",
      "0.29719767993136853 0.3315194895144786 0.03923862559564925 0.4434996766017909\n",
      "0.3490288377600581 0.03923862559564925 0.3362613344273665 0.10143527145869578\n",
      "0.3362613344273665 2.0405163636765264 2.014340483495246 0.46819988468034385\n",
      "1.709300330278962 0.5600172516942332 0.5423725745298027 1.7149807379923674\n",
      "0.5423725745298027 0.4434996766017909 0.4446782779798562 0.541406688027447\n",
      "0.541406688027447 0.46819988468034385 0.4926133651000653 0.5192922167530787\n",
      "2.014340483495246 0.13609141530698873 0.5547034122698343 1.9412348083589275\n",
      "1.7149807379923674 0.5122425133552111 1.5233214463119018 0.9397037274479251\n",
      "0.5547034122698343 0.5192922167530787 0.4582562565463871 0.6061035268831688\n",
      "1.9412348083589275 0.6061035268831688 1.364829840990333 1.507645041654978\n",
      "1.364829840990333 0.4926133651000653 0.4612747072420146 1.3757376446080485\n",
      "0.4582562565463871 0.4446782779798562 0.6175380920114003 0.1624323628035921\n",
      "1.5233214463119018 0.9397037274479251 0.5665966553338638 1.6977984433783024\n",
      "1.3757376446080485 0.5665966553338638 1.262925279297381 0.7865783975795767\n",
      "0.6175380920114003 1.262925279297381 1.2996364026018372 0.5359839337196628\n",
      "0.10143527145869578 0.7865783975795767 0.7507584431711409 0.25564907557430894\n",
      "1.6977984433783024 1.507645041654978 1.5987329609187413 1.6123169805086783\n",
      "0.5359839337196628 0.25564907557430894 0.5244434802890441 0.2785574680921651\n",
      "0.4612747072420146 0.1624323628035921 0.25448801153344414 0.4176056513182235\n",
      "0.2785574680921651 1.6123169805086783 0.3190955231944984 1.6047860778757304\n",
      "0.25448801153344414 0.3190955231944984 0.3734054321972974 0.1647861770372947\n",
      "0.4176056513182235 0.1647861770372947 0.4104917048324575 0.18178427990128018\n",
      "1.2996364026018372 0.5244434802890441 0.14803538757135204 1.3936216369632504\n",
      "1.3936216369632504 0.18178427990128018 1.393772077340367 0.18062720685897216\n",
      "1.393772077340367 0.18062720685897216 1.3993996815877414 0.1300281608094333\n",
      "0.3734054321972974 1.3993996815877414 0.5652582204465044 1.3335044918709398\n",
      "1.3335044918709398 0.1300281608094333 0.9962787136659716 0.8958628673739828\n",
      "0.7507584431711409 0.9962787136659716 0.6940068491863074 1.0366117926105083\n",
      "1.0366117926105083 1.5987329609187413 1.1397600872815719 1.5269112719300628\n",
      "0.14803538757135204 0.5652582204465044 0.23173909338914825 0.5364031360375562\n",
      "1.5269112719300628 1.6047860778757304 1.4190424263407784 1.7009159239467797\n",
      "0.6940068491863074 1.1397600872815719 1.2995271610919912 0.3031958457198788\n",
      "0.4104917048324575 1.7009159239467797 1.6336343200511896 0.6267833185582337\n",
      "1.2995271610919912 1.6336343200511896 1.7921553628524742 1.0703789466651703\n",
      "0.23173909338914825 1.4190424263407784 0.9340867594385937 1.093099419541267\n",
      "0.5364031360375562 1.0703789466651703 1.0879074443021388 0.49989679579584567\n",
      "1.7921553628524742 0.49989679579584567 1.031997709257311 1.5481273782009992\n",
      "0.3031958457198788 0.6267833185582337 0.6101488724604857 0.33541526906189406\n",
      "1.5481273782009992 0.33541526906189406 1.4728137137225203 0.5831136651856487\n",
      "1.0879074443021388 1.4728137137225203 1.728910540210074 0.6029852292118296\n",
      "0.9340867594385937 0.5831136651856487 0.8882906149059856 0.6507529517064675\n",
      "1.728910540210074 0.6101488724604857 1.816829773609033 0.24605462064761416\n",
      "1.816829773609033 1.031997709257311 1.91655062867732 0.8323000576121311\n",
      "0.6029852292118296 1.093099419541267 1.1280484880940773 0.5347561464422491\n",
      "1.91655062867732 0.8323000576121311 1.5669297175843364 1.382252132693475\n",
      "1.5669297175843364 0.6507529517064675 1.6964306890719685 0.029513745584284008\n",
      "0.8958628673739828 0.5347561464422491 0.9550326561045238 0.42005599516164155\n",
      "0.8882906149059856 0.029513745584284008 0.8877662379674153 0.04245449839122699\n",
      "0.8877662379674153 0.24605462064761416 0.8825700435751176 0.264086894412945\n",
      "0.8825700435751176 1.382252132693475 0.7126140475568334 1.4770687388799861\n",
      "1.1280484880940773 0.04245449839122699 0.8661780551814092 0.7239000985268169\n",
      "1.6964306890719685 0.8661780551814092 1.5062676428305886 1.1658899151569262\n",
      "1.4770687388799861 0.42005599516164155 1.4241948688560726 0.5743240147963369\n",
      "1.5062676428305886 1.1658899151569262 1.1643968175695034 1.5074221563109171\n",
      "1.1643968175695034 0.7239000985268169 0.7286647289979378 1.1614211183405803\n",
      "1.5074221563109171 1.1614211183405803 1.4673832056425105 1.2116134281456477\n",
      "0.9550326561045238 0.5743240147963369 0.5971285302863257 0.9409425946974327\n",
      "0.5971285302863257 1.2116134281456477 0.4251167695827272 1.2821253110224065\n",
      "0.7286647289979378 0.9409425946974327 0.9648732719947314 0.6966669382077466\n",
      "0.7126140475568334 0.9648732719947314 1.0079932995011998 0.650191294886233\n",
      "0.650191294886233 1.2821253110224065 1.0754787520444788 0.9539074834652413\n",
      "1.0079932995011998 0.264086894412945 0.6304838808388888 0.8296279019188803\n",
      "0.8296279019188803 0.9539074834652413 0.3221281714699661 1.222479195650678\n",
      "0.6966669382077466 1.222479195650678 1.1952867725856764 0.742354186269737\n",
      "1.4673832056425105 1.1952867725856764 0.9505746996194655 1.636560931149016\n",
      "0.6304838808388888 1.636560931149016 0.8515464660077797 1.5332026029167383\n",
      "0.9505746996194655 0.3221281714699661 0.9641279244472793 0.2789554869727461\n",
      "0.8515464660077797 0.4251167695827272 0.5987445644274234 0.739838224289207\n",
      "0.5987445644274234 1.0754787520444788 1.1745140933480744 0.3683289888907544\n",
      "1.5332026029167383 0.742354186269737 0.6244686671884467 1.584878179281534\n",
      "0.9641279244472793 0.739838224289207 1.1859426838480647 0.26541138529775704\n",
      "1.1745140933480744 1.1859426838480647 1.4920581830494775 0.7481348696866703\n",
      "0.7481348696866703 0.6244686671884467 0.6685343189372187 0.7090336832227051\n",
      "1.4241948688560726 0.7090336832227051 0.629082073111662 1.461271889043875\n",
      "0.3683289888907544 0.26541138529775704 0.17700714459394506 0.4180644905581651\n",
      "0.4180644905581651 1.584878179281534 1.197049482597277 1.119682677209038\n",
      "1.461271889043875 1.119682677209038 1.6672061631498065 0.7806589786245675\n",
      "0.6685343189372187 1.6672061631498065 1.3592857695834881 1.1742473004650142\n",
      "1.4920581830494775 0.17700714459394506 1.1811855490116114 0.9286387078128655\n",
      "0.9286387078128655 0.7806589786245675 1.1951613220993598 0.20829715483705533\n",
      "1.1742473004650142 0.20829715483705533 1.149985973724798 0.3158744807654051\n",
      "1.149985973724798 0.3158744807654051 0.6869979740195423 0.9748221432936521\n",
      "1.1951613220993598 0.2789554869727461 1.0737710513310545 0.594342055451147\n",
      "1.1811855490116114 1.3592857695834881 1.4610202668430399 1.0527473032308987\n",
      "1.4610202668430399 1.0527473032308987 1.3337908541034773 1.209900434786249\n",
      "1.209900434786249 0.594342055451147 1.2144394344457887 0.585011453765515\n",
      "1.197049482597277 0.9748221432936521 0.7216290198006389 1.3647187375512977\n",
      "0.629082073111662 0.585011453765515 0.23509605339730277 0.8262641837961513\n",
      "0.23509605339730277 0.6869979740195423 0.7000963583982877 0.19261739170542114\n",
      "0.8262641837961513 0.7216290198006389 0.5426773781521327 0.9533950948503344\n",
      "1.2144394344457887 0.5426773781521327 0.6533533814508667 1.1586592405197478\n",
      "0.7000963583982877 1.3647187375512977 0.45563717679039584 1.4645773816335645\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.1586592405197478 0.19261739170542114 0.9033310984365543 0.750723399013649\n",
      "1.3337908541034773 0.6533533814508667 1.4242406939889474 0.4211972567921665\n",
      "0.9033310984365543 1.4645773816335645 0.6638685434630359 1.5875366254658463\n",
      "1.0737710513310545 0.750723399013649 1.213842605991948 0.4931085279954916\n",
      "1.4242406939889474 0.4211972567921665 1.2926650825376311 0.7313587819472351\n",
      "1.213842605991948 0.45563717679039584 1.1250836019676758 0.6443648016289274\n",
      "0.6638685434630359 1.5875366254658463 1.503551052988464 0.8368561472872742\n",
      "0.7313587819472351 0.9533950948503344 1.1193562806581652 0.4369089055708755\n",
      "1.1250836019676758 0.8368561472872742 1.1583684249885855 0.7901417054291736\n",
      "1.503551052988464 0.4931085279954916 0.9344376075532299 1.276968342174071\n",
      "0.9344376075532299 1.276968342174071 1.3096597113050825 0.8880389799490155\n",
      "1.2926650825376311 0.6443648016289274 0.3580287774354546 1.3992871069649653\n",
      "0.4369089055708755 0.8880389799490155 0.47314561462014004 0.8692731728529058\n",
      "0.47314561462014004 0.7901417054291736 0.7937631903719491 0.46704462838505895\n",
      "0.3580287774354546 1.3096597113050825 0.70989397714679 1.1573433829673676\n",
      "0.70989397714679 0.7937631903719491 0.8699226064602378 0.6142020188408442\n",
      "1.1583684249885855 0.6142020188408442 0.8953982816966981 0.9577700376882257\n",
      "0.8953982816966981 0.9577700376882257 1.1406542985119337 0.6465054518292582\n",
      "1.1406542985119337 1.1193562806581652 0.9212745862137601 1.305872830163526\n",
      "1.305872830163526 0.6465054518292582 1.143417575092005 0.9032548902579881\n",
      "0.8699226064602378 0.8692731728529058 1.225158054078979 0.10671894301266907\n",
      "0.9212745862137601 1.1573433829673676 0.7402109503539019 1.280733507907816\n",
      "1.225158054078979 0.9032548902579881 0.9051743826692416 1.2237405734913416\n",
      "1.2237405734913416 0.46704462838505895 0.6342453110627209 1.1460386387496748\n",
      "0.9051743826692416 1.143417575092005 0.878810951307999 1.1638022709769271\n",
      "0.7402109503539019 0.6342453110627209 0.5186575986192459 0.8253324548467676\n",
      "0.878810951307999 1.280733507907816 0.7253054786899629 1.373506086262108\n",
      "1.3992871069649653 0.8253324548467676 1.2769514067526755 1.0042774385268927\n",
      "1.0042774385268927 0.10671894301266907 0.8228478481102698 0.5855625715431068\n",
      "0.7253054786899629 1.1638022709769271 0.7644487420192408 1.1384734885687628\n",
      "0.8228478481102698 1.1460386387496748 1.1100882406763364 0.8707394791549455\n",
      "1.373506086262108 0.5855625715431068 0.7034344419941598 1.317035489274148\n",
      "1.2769514067526755 0.8707394791549455 1.3437722162137498 0.7635891347437115\n",
      "1.1384734885687628 0.7635891347437115 1.1612443714152108 0.7284928007393559\n",
      "0.7644487420192408 0.5186575986192459 0.6337423359559491 0.6721296269302369\n",
      "0.6337423359559491 0.6721296269302369 0.7155185788906617 0.5843121999775208\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAN8UlEQVR4nO3db2hld5nA8e+zScTbcd1UGsWkLa1Q0pUOJW7YrQ5IaYV0V7FDQahQ6crCvNnVKhKZ2Td92UJE9MUiDLUqWCoyhli6i7G0lmX3RdlMU0jbMSjVbefO2IlIqpSwnY7PvsidZmaamST3nOTk/vL9QEnuyf3zcEi+Pfnl3DORmUiSyvIXTQ8gSaqfcZekAhl3SSqQcZekAhl3SSqQcZekAm0Y94h4NCLORMSLF2z7QEQ8FRG/6ny8envHlCRtxWaO3L8P3HXJtsPA05l5E/B057YkaZeIzbyJKSJuAJ7MzFs6txeB2zPzdER8GHg2M0e3dVJJ0qb1d/m4D2XmaYBO4D94uTtGxCHgEMC+ffv+5uabb+7yJaXdY6H9xmW/tn/kr3ZwEu0Fx48f/31mDm3lMd3GfdMy8yhwFGB8fDzn5ua2+yWlbXfg4WdoL6+8a/vIYIv/PnxHAxOpZBHxv1t9TLdny7zeWY6h8/FMl88j9aTJiVFaA30XbWsN9DE54eqkdoduj9yfAO4HHu58/GltE0k94ODYCABTs4ucWl5heLDF5MToO9ulzZqZb2/L99GGf1CNiMeB24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iPgXYBboAx7NzJc2eNjRbl+vQO6LNe6LNe6LNe6LNVveF5H5rmVySVKP8x2qklQg4y5JBdqRuHuZglURcV1E/CIiTkTESxHxQNMzNS0i+iJiPiKebHqWJkXEYEQci4hfdr4/Pt70TE2JiK92fj5ejIjHI+K9Tc+0kyLi0Yg4c+F7giLiAxHxVET8qvPx6o2eZ9vj7mUKLvI28LXM/GvgNuCf9/C+OO8B4ETTQ+wC3wZ+lpk3A7eyR/dJRIwAXwbGM/MWVk/WuLfZqXbc94G7Ltl2GHg6M28Cnu7cvqKdOHL3MgUdmXk6M5/vfP4nVn+AR5qdqjkRcS3waeCRpmdpUkS8H/gk8F2AzHwrM5cbHapZ/UArIvqBq9hj75/JzP8E/nDJ5ruBH3Q+/wFwcKPn2Ym4r3eZgj0btPMi4gZgDHiu4VGa9C3g68CfG56jaR8BloDvdZaoHomIfU0P1YTMbAPfAF4FTgNvZObPm51qV/hQZp6G1YNE4IMbPWAn4r6pyxTsJRHxPuAnwFcy849Nz9OEiPgMcCYzjzc9yy7QD3wM+E5mjgFvsolfu0vUWUu+G7gRGAb2RcR9zU7Vm3Yi7l6m4AIRMcBq2B/LzOmm52nQAeCzEfFbVpfq7oiIHzY7UmNOAicz8/xvccdYjf1e9CngN5m5lJlngWngEw3PtBu8HhEfBuh8PLPRA3Yi7l6moCMigtV11ROZ+c2m52lSZh7JzGsz8wZWvyeeycw9eYSWmb8DXouI81f+uxN4ucGRmvQqcFtEXNX5ebmTPfrH5Us8Adzf+fx+4KcbPaDKVSE3pcvLFJTqAPAFYCEiXuhs+9fM/I/mRtIu8SXgsc4B0CvAFxuepxGZ+VxEHAOeZ/Xssnn22GUIIuJx4Hbgmog4CTwIPAz8OCL+idX/AX5uw+fx8gOSVB7foSpJBTLuklQg4y5JBTLuklQg4y5JBTLuklQg4y5JBfp/50jGHF03rOwAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "碰撞次数 243 最大速度 2.0405163636765264 最小速度 0.029513745584284008\n"
     ]
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "num=8\n",
    "x = np.arange(1,num+1,1)*1.0\n",
    "y = np.zeros(num)+5.0\n",
    "v=np.zeros(num)+1.0\n",
    "o=np.arange(2*np.pi/num,2*(num+1)*np.pi/num,2*np.pi/num)\n",
    "vx=v*np.cos(o)\n",
    "vy=v*np.sin(o)\n",
    "dt=1\n",
    "l=len(x)\n",
    "\n",
    "#计算分子路径，碰到边界反弹.\n",
    "def calulatePath(x,y,vx,vy,l):\n",
    "    s=0\n",
    "    flag=False\n",
    "    vMax=1\n",
    "    vMin=1\n",
    "    for j in range(l): #计算分子间碰撞，为了计算方便dx<0.3 and dy<0.3 认为发生分子间碰撞\n",
    "        s=s+1\n",
    "        for k in range(s,l):\n",
    "            dx=abs(x[j]-x[k])\n",
    "            dy=abs(y[j]-y[k])\n",
    "            if(dx<0.3)and(dy<0.3)and(dx!=0):\n",
    "                v1=np.sqrt(vx[j]*vx[j]+vy[j]*vy[j])\n",
    "                v2=np.sqrt(vx[k]*vx[k]+vy[k]*vy[k])\n",
    "\n",
    "                angle=np.arctan(dy/dx)\n",
    "                vxjTemp=vx[j]*np.cos(angle)+vy[j]*np.sin(angle)\n",
    "                vyjTemp=vy[j]*np.cos(angle)+vx[j]*np.cos(angle+np.pi/2)\n",
    "                vxkTemp=vx[k]*np.cos(angle)+vy[k]*np.sin(angle)\n",
    "                vykTemp=vy[k]*np.cos(angle)+vx[k]*np.cos(angle+np.pi/2)\n",
    "                #转换坐标系到质心连线为x'，x'动量互换再转换回xy坐标系\n",
    "                vx[j]=vxkTemp*np.cos(angle)+vyjTemp*np.cos(angle+np.pi/2)\n",
    "                vy[j]=vxkTemp*np.sin(angle)+vyjTemp*np.sin(angle+np.pi/2)\n",
    "                vx[k]=vxjTemp*np.cos(angle)+vykTemp*np.cos(angle+np.pi/2)\n",
    "                vy[k]=vxjTemp*np.sin(angle)+vykTemp*np.sin(angle+np.pi/2)                \n",
    "                \n",
    "                v3=np.sqrt(vx[j]*vx[j]+vy[j]*vy[j])\n",
    "                v4=np.sqrt(vx[k]*vx[k]+vy[k]*vy[k])\n",
    "                \n",
    "                vMax=np.max([v1,v2,v3,v4])\n",
    "                vMin=np.min([v1,v2,v3,v4])\n",
    "                flag=True\n",
    "                print(v1,v2,v3,v4)\n",
    "                \n",
    "      \n",
    "    for j in range(l): #碰到边界反弹\n",
    "        x[j]=x[j]+vx[j]*dt\n",
    "        y[j]=y[j]+vy[j]*dt\n",
    "        if(x[j]>10):\n",
    "            x[j]=20-x[j]\n",
    "            vx[j]=-vx[j]\n",
    "        if(y[j]>10):\n",
    "            y[j]=20-y[j]\n",
    "            vy[j]=-vy[j]\n",
    "        if(x[j]<0):\n",
    "            x[j]=-x[j]\n",
    "            vx[j]=-vx[j]\n",
    "        if(y[j]<0):\n",
    "            y[j]=-y[j]\n",
    "            vy[j]=-vy[j]        \n",
    "    return flag,vMax,vMin\n",
    "vMax=1\n",
    "vMin=1\n",
    "collideNum=0\n",
    "for i in range(3000):\n",
    "    plt.clf()\n",
    "    plt.xlim(0, 10) \n",
    "    plt.ylim(0, 10) \n",
    "    \n",
    "    flag,vTemp1,vTemp2=calulatePath(x,y,vx,vy,l)\n",
    "    if(flag==True):\n",
    "        collideNum=collideNum+1\n",
    "        if(vMax<vTemp1):\n",
    "            vMax=vTemp1\n",
    "        if(vMin>vTemp2):\n",
    "            vMin=vTemp2\n",
    "  #  plt.scatter(x, y)\n",
    "  #  plt.scatter(x[0], y[0],c='r')\n",
    "  #  plt.savefig('molecule/test'+\"{:0>3d}\".format(i)+'.jpg')    \n",
    "plt.scatter(x, y)\n",
    "plt.show()\n",
    "print('碰撞次数',collideNum,'最大速度',vMax,'最小速度',vMin)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "06d40a7f",
   "metadata": {},
   "source": [
    "# 输出速率的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "a990fc8a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "碰撞次数 100 最大速度 2.387635761264161 最小速度 0.07154811839309323\n"
     ]
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "num=1001\n",
    "x = np.arange(1,num+1,1)*1.0/101\n",
    "y = np.zeros(num)+5.0\n",
    "v=np.zeros(num)+1.0\n",
    "o=np.arange(2*np.pi/num,2*(num+1)*np.pi/num,2*np.pi/num)\n",
    "vx=v*np.cos(o)\n",
    "vy=v*np.sin(o)\n",
    "dt=0.5\n",
    "l=len(x)\n",
    "\n",
    "#计算分子路径，碰到边界反弹.\n",
    "def calulatePath(x,y,vx,vy,l):\n",
    "    s=0\n",
    "    flag=False\n",
    "    vMax=1\n",
    "    vMin=1\n",
    "    for j in range(l): #计算分子间碰撞，为了计算方便dx<0.3 and dy<0.3 认为发生分子间碰撞\n",
    "        s=s+1\n",
    "        for k in range(s,l):\n",
    "            dx=abs(x[j]-x[k])\n",
    "            dy=abs(y[j]-y[k])\n",
    "            if(dx<0.08)and(dy<0.08)and(dx!=0):\n",
    "                v1=np.sqrt(vx[j]*vx[j]+vy[j]*vy[j])\n",
    "                v2=np.sqrt(vx[k]*vx[k]+vy[k]*vy[k])\n",
    "\n",
    "                angle=np.arctan(dy/dx)\n",
    "                vxjTemp=vx[j]*np.cos(angle)+vy[j]*np.sin(angle)\n",
    "                vyjTemp=vy[j]*np.cos(angle)+vx[j]*np.cos(angle+np.pi/2)\n",
    "                vxkTemp=vx[k]*np.cos(angle)+vy[k]*np.sin(angle)\n",
    "                vykTemp=vy[k]*np.cos(angle)+vx[k]*np.cos(angle+np.pi/2)\n",
    "                #转换坐标系到质心连线为x'，x'动量互换再转换回xy坐标系\n",
    "                vx[j]=vxkTemp*np.cos(angle)+vyjTemp*np.cos(angle+np.pi/2)\n",
    "                vy[j]=vxkTemp*np.sin(angle)+vyjTemp*np.sin(angle+np.pi/2)\n",
    "                vx[k]=vxjTemp*np.cos(angle)+vykTemp*np.cos(angle+np.pi/2)\n",
    "                vy[k]=vxjTemp*np.sin(angle)+vykTemp*np.sin(angle+np.pi/2)                \n",
    "                \n",
    "                v3=np.sqrt(vx[j]*vx[j]+vy[j]*vy[j])\n",
    "                v4=np.sqrt(vx[k]*vx[k]+vy[k]*vy[k])\n",
    "                \n",
    "                vMax=np.max([v1,v2,v3,v4])\n",
    "                vMin=np.min([v1,v2,v3,v4])\n",
    "                flag=True\n",
    "                \n",
    "     \n",
    "    for j in range(l): #碰到边界反弹\n",
    "        x[j]=x[j]+vx[j]*dt\n",
    "        y[j]=y[j]+vy[j]*dt\n",
    "        if(x[j]>10):\n",
    "            x[j]=20-x[j]\n",
    "            vx[j]=-vx[j]\n",
    "        if(y[j]>10):\n",
    "            y[j]=20-y[j]\n",
    "            vy[j]=-vy[j]\n",
    "        if(x[j]<0):\n",
    "            x[j]=-x[j]\n",
    "            vx[j]=-vx[j]\n",
    "        if(y[j]<0):\n",
    "            y[j]=-y[j]\n",
    "            vy[j]=-vy[j]        \n",
    "    return flag,vMax,vMin\n",
    "\n",
    "\n",
    "vMax=1\n",
    "vMin=1\n",
    "collideNum=0\n",
    "for i in range(100):   \n",
    "    \n",
    "    flag,vTemp1,vTemp2=calulatePath(x,y,vx,vy,l)\n",
    "    vD=np.sqrt(vx*vx+vy*vy)\n",
    "    sX=\" \"\n",
    "    for i in range(len(vD)):\n",
    "        sX=sX+\" \"+str(vD[i])\n",
    "    with open(\"test.txt\",\"a+\") as f:\n",
    "        f.write('\\r\\n')\n",
    "        f.write(sX)\n",
    "    if(flag==True):\n",
    "        collideNum=collideNum+1\n",
    "        if(vMax<vTemp1):\n",
    "            vMax=vTemp1\n",
    "        if(vMin>vTemp2):\n",
    "            vMin=vTemp2\n",
    "  #  plt.scatter(x, y)\n",
    "  #  plt.scatter(x[0], y[0],c='r')\n",
    "  #  plt.savefig('molecule/test'+\"{:0>3d}\".format(i)+'.jpg')    \n",
    "print('碰撞次数',collideNum,'最大速度',vMax,'最小速度',vMin)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "e7573c43",
   "metadata": {},
   "outputs": [],
   "source": [
    "def groupData(data,start,end,section):\n",
    "    y = np.zeros(section)\n",
    "    \n",
    "    width=(end-start)/section\n",
    "    print(width)\n",
    "    for i in range(len(data)):\n",
    "        k=int((data[i]-start)/width)\n",
    "        print(i,k,y)\n",
    "        if k>section-1:\n",
    "            k=section-1\n",
    "        y[k]=y[k]+1\n",
    "    return y"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ce330d1d",
   "metadata": {},
   "source": [
    "# 画速率分布图的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ec09c7a8",
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "num=10001\n",
    "x = np.arange(1,num+1,1)*1.0/1001\n",
    "y = np.zeros(num)+5.0\n",
    "v=np.zeros(num)+1.0\n",
    "o=np.arange(2*np.pi/num,2*(num+1)*np.pi/num,2*np.pi/num)\n",
    "vx=v*np.cos(o)\n",
    "vy=v*np.sin(o)\n",
    "dt=0.5\n",
    "l=len(x)\n",
    "\n",
    "#计算分子路径，碰到边界反弹.\n",
    "def calulatePath(x,y,vx,vy,l):\n",
    "    s=0\n",
    "    flag=False\n",
    "    vMax=1\n",
    "    vMin=1\n",
    "    for j in range(l): #计算分子间碰撞，为了计算方便dx<0.3 and dy<0.3 认为发生分子间碰撞\n",
    "        s=s+1\n",
    "        for k in range(s,l):\n",
    "            dx=abs(x[j]-x[k])\n",
    "            dy=abs(y[j]-y[k])\n",
    "            if(dx<0.05)and(dy<0.05)and(dx!=0):\n",
    "                v1=np.sqrt(vx[j]*vx[j]+vy[j]*vy[j])\n",
    "                v2=np.sqrt(vx[k]*vx[k]+vy[k]*vy[k])\n",
    "\n",
    "                angle=np.arctan(dy/dx)\n",
    "                vxjTemp=vx[j]*np.cos(angle)+vy[j]*np.sin(angle)\n",
    "                vyjTemp=vy[j]*np.cos(angle)+vx[j]*np.cos(angle+np.pi/2)\n",
    "                vxkTemp=vx[k]*np.cos(angle)+vy[k]*np.sin(angle)\n",
    "                vykTemp=vy[k]*np.cos(angle)+vx[k]*np.cos(angle+np.pi/2)\n",
    "                #转换坐标系到质心连线为x'，x'动量互换再转换回xy坐标系\n",
    "                vx[j]=vxkTemp*np.cos(angle)+vyjTemp*np.cos(angle+np.pi/2)\n",
    "                vy[j]=vxkTemp*np.sin(angle)+vyjTemp*np.sin(angle+np.pi/2)\n",
    "                vx[k]=vxjTemp*np.cos(angle)+vykTemp*np.cos(angle+np.pi/2)\n",
    "                vy[k]=vxjTemp*np.sin(angle)+vykTemp*np.sin(angle+np.pi/2)                \n",
    "                \n",
    "                v3=np.sqrt(vx[j]*vx[j]+vy[j]*vy[j])\n",
    "                v4=np.sqrt(vx[k]*vx[k]+vy[k]*vy[k])\n",
    "                \n",
    "                vMax=np.max([v1,v2,v3,v4])\n",
    "                vMin=np.min([v1,v2,v3,v4])\n",
    "                flag=True     \n",
    "    for j in range(l): #碰到边界反弹\n",
    "        x[j]=x[j]+vx[j]*dt\n",
    "        y[j]=y[j]+vy[j]*dt\n",
    "        if(x[j]>10):\n",
    "            x[j]=20-x[j]\n",
    "            vx[j]=-vx[j]\n",
    "        if(y[j]>10):\n",
    "            y[j]=20-y[j]\n",
    "            vy[j]=-vy[j]\n",
    "        if(x[j]<0):\n",
    "            x[j]=-x[j]\n",
    "            vx[j]=-vx[j]\n",
    "        if(y[j]<0):\n",
    "            y[j]=-y[j]\n",
    "            vy[j]=-vy[j]        \n",
    "    return flag,vMax,vMin\n",
    "\n",
    "def groupData(data,start,end,section):\n",
    "    y = np.zeros(section)\n",
    "    width=(end-start)/section\n",
    "    for i in range(len(data)):\n",
    "        k=int((data[i]-start)/width)\n",
    "        if k>section-1:\n",
    "            k=section-1\n",
    "        y[k]=y[k]+1\n",
    "    return y\n",
    "\n",
    "vMax=1\n",
    "vMin=1\n",
    "collideNum=0\n",
    "for i in range(60):   \n",
    "\n",
    "    \n",
    "    vD=np.sqrt(vx*vx+vy*vy)\n",
    "    yG=groupData(vD,0,3,100)/1000\n",
    "    xG= np.arange(0,100,1)*3/100\n",
    "   \n",
    "    plt.clf()\n",
    "    plt.xlim(0, 3) \n",
    "    plt.ylim(0, 1)  \n",
    "    plt.plot(xG, yG)\n",
    "    plt.savefig('molecule/test'+\"{:0>3d}\".format(i)+'.jpg')   \n",
    "\n",
    "    flag,vTemp1,vTemp2=calulatePath(x,y,vx,vy,l)\n",
    "    \n",
    "    \n",
    "\n",
    "    if(flag==True):\n",
    "        collideNum=collideNum+1\n",
    "        if(vMax<vTemp1):\n",
    "            vMax=vTemp1\n",
    "        if(vMin>vTemp2):\n",
    "            vMin=vTemp2\n",
    "\n",
    "print('碰撞次数',collideNum,'最大速度',vMax,'最小速度',vMin)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
